package com.wondertek.poms.dao.po;

import java.time.LocalDateTime;

import javax.persistence.*;

import lombok.experimental.Accessors;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.Proxy;
import org.springframework.format.annotation.DateTimeFormat;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.wondertek.poms.common.constant.CurrentUser;

import lombok.Data;

/**
 * <p><b>ContentBlack Description:</b> ContentBlack po类 ; 黑名单表</p>
 * @author 窦再兴
 * <p><b>DATE</b> 2020-12-03 10:19:26</p>
 */
@Data
@Accessors(chain = true)
@Entity
@Table(name = "CONTENT_BLACK")
@DynamicUpdate
@DynamicInsert
@Proxy(lazy = false)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class ContentBlack implements java.io.Serializable {
	
	/**
	 * <b>Fields</b> serialVersionUID : 
	 */
	private static final long serialVersionUID = 8135475592493193542L;

	/**
	 * <b>Fields</b> id : 主键ID
	 */
	@Id
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "CONTENT_BLACK_SEQ")
	@SequenceGenerator(name = "CONTENT_BLACK_SEQ", allocationSize = 1, sequenceName = "CONTENT_BLACK_SEQ")
	private Long id;
	
	/**
	 * <b>Fields</b> contentId : 内容id
	 */
	@Column(name = "content_id")
	private String contentId;
	
	/**
	 * <b>Fields</b> packageId : 二级产品id
	 */
	@Column(name = "package_id")
	private Long packageId;
	
	/**
	 * <b>Fields</b> prdInfoId : 商品包id
	 */
	@Column(name = "prd_info_id")
	private Long prdInfoId;

	/**
	 * <b>Fields</b> contentId : 内容名称
	 */
	@Column(name = "content_name")
	private String contentName;

	/**
	 * <b>Fields</b> packageId : 二级产品名称
	 */
	@Column(name = "package_name")
	private String packageName;

	/**
	 * <b>Fields</b> prdInfoId : 商品包名称
	 */
	@Column(name = "prd_info_name")
	private String prdInfoName;
	
	/**
	 * <b>Fields</b> remarks : 备注
	 */
	private String remarks;
	
	/**
	 * <b>Fields</b> createdBy : 创建人
	 */
	@Column(name = "created_by")
	private String createdBy;
	
	/**
	 * <b>Fields</b> createdTime : 创建时间
	 */
	@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@Column(name = "created_time")
	private LocalDateTime createdTime;
	
	/**
	 * <b>Fields</b> updatedBy : 更新人
	 */
	@Column(name = "updated_by")
	private String updatedBy;
	
	/**
	 * <b>Fields</b> updatedTime : 更新时间
	 */
	@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@Column(name = "updated_time")
	private LocalDateTime updatedTime;
	
	/**
	 * <b>Fields</b> deleted : 是否有效 0正常 1删除 2停用
	 */
	private Integer deleted = 0;
	
	public static void putTimeAndUser(ContentBlack contentBlack) {
		if (contentBlack.id == null) {
			contentBlack.setCreatedBy(CurrentUser.currUserName());
			contentBlack.setCreatedTime(LocalDateTime.now());
			contentBlack.setUpdatedBy(CurrentUser.currUserName());
			contentBlack.setUpdatedTime(LocalDateTime.now());
		}
		contentBlack.setUpdatedBy(CurrentUser.currUserName());
		contentBlack.setUpdatedTime(LocalDateTime.now());
	}
}